package com.besall.allbase.common.utils;

import java.lang.ref.WeakReference;

public class CacheManager<T> {
    private WeakReference<T> weakReference;

    public void cacheObject(T object) {
        weakReference = new WeakReference<>(object);
    }

    public T getCachedObject() {
        return weakReference != null ? weakReference.get() : null;
    }

    public void clearCache() {
        if (weakReference != null) {
            weakReference.clear();
        }
    }
}